#include "statemanager.h"

#include <windows.h>

#include "battlefield.h"
#include "fight.h"
#include "gameover.h"


StateManager* StateManager::Instance = nullptr;

StateManager::StateManager():
	FightingPlayer(nullptr),
	FightingEnemy(nullptr),
	Winner(Teams::Player),
	enumCurrentState(State::Battlefield),
	States()
{
	Instance = this;
	States.push_back(new Battlefield());
	States.push_back(new Fight());
	States.push_back(new Gameover());
}

void StateManager::Draw(){
	CurrentState()->Draw();
}

void StateManager::Update(){
	CurrentState()->Update();
}

GameState* StateManager::CurrentState(){
	return States[(int)enumCurrentState];
}

void StateManager::StartBattle(Player* p, Enemy* e){
	enumCurrentState = State::Fight;
	this->FightingPlayer = p;
	this->FightingEnemy = e;
}

void StateManager::FightOver(){
	enumCurrentState = State::Battlefield;
}

void StateManager::Quit(){
	PostQuitMessage(0);
}

void StateManager::EndGame(Teams winner){
	Winner = winner;
	enumCurrentState = State::GameOver;
}
